#pragma once
#include <vector>
#include "EnumsUn.h"

class CNumSpinCtrl;

namespace nsUnitUtils {
double computeUnitFactor( nsEnumsUn::EUNIT Unit, size_t nDPI );
};

class CSpinUnits
{
public:
	CSpinUnits();
	~CSpinUnits();
	void addSpinControl( CNumSpinCtrl &SpinControl, const int nPixelMin, const int nPixelMax );
	void setUnit( nsEnumsUn::EUNIT Unit );
	void setDPI( int nDPI );
	nsEnumsUn::EUNIT getCurrentUnit() const;
	void getFormattedCoordinate( OUT CString &str, IN int nPixel );

private:
	struct SSpin {
		CNumSpinCtrl *pSpinControl;
		int nPixelMin;
		int nPixelMax;
	};

	nsEnumsUn::EUNIT CurrentUnit_;
	size_t nDPI_;
	double nPixelToUnitFactor_;
	std::vector<SSpin> vSpin_;

	double roundNumber( double dVal, int iDigits );
	void setControlRanges( size_t iStart, size_t iEnd );
};
